update perform 5

Documentation Version for Comments and Changes

You are invited to make any changes...add any comments.

Changes will `eventually` be merged into the offical documentation.

Leave any commnents here...

...

... back to index page OE documentation



Low Level Memory Manipulation

Sequence Manipulation

Other routines are reasonably fast, but you might be able to do the job faster in some cases if speed was crucial.

x = repeat(0,100) -- Pre-allocate all the elements first. 
for i = 1 to 100 do 
    x[i] = i 
end for 

is somewhat faster than:

x = {} 
for i = 1 to 100 do 
    x = append(x, i) 
end for 

because append has to allocate and reallocate space as x grows in size. With repeat(), the space for x is allocated once at the beginning. (append is smart enough not to allocate space with every append to x. It will allocate somewhat more than it needs, to reduce the number of reallocations.)

These built-in operations are also optimize to make changes in place (where possible), rather than creating copies of sequences via slices.

Bitwise operations vs Arithmetic

You can replace:

remainder(x, p) 

with:

and_bits(x, p-1) 

for greater speed when p is a positive power of 2. x must be a non-negative integer that fits in 32-bits.

arctan is faster than arccos or arcsin.

Searching

Euphoria's find is the fastest way to search for a value in a sequence up to about 50 elements. Beyond that, you might consider a map or other implementation of a hash table (demo\hash.ex) or a binary tree (demo\tree.ex).

Sorting

In most cases you can just use the shell sort routine in sort.e.

If you have a huge amount of data to sort, you might try one of the sorts in demo\allsorts.e (e.g. great sort). If your data is too big to fit in memory, don't rely on Euphoria's automatic memory swapping capability. Instead, sort a few thousand records at a time, and write them out to a series of temporary files. Then merge all the sorted temporary files into

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu